import 'package:boss/color_constant.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class TextWithCopy extends StatelessWidget {
  final String text;
  final String copyText;
  final TextStyle textStyle;
  final TextStyle copyStyle;
  final String clipboardText;

  const TextWithCopy(
    this.text, {
    Key key,
    this.copyText = '复制',
    this.textStyle,
    this.copyStyle,
    this.clipboardText = '',
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
        Text(
          text,
          style: textStyle ?? TextStyleConstant().normal_1_28,
        ),
        GestureDetector(
          child: Padding(
            padding: EdgeInsets.symmetric(
              horizontal: 20.w,
            ),
            child: Container(
              padding: EdgeInsets.symmetric(
                horizontal: 9.w,
                vertical: 4.w,
              ),
              decoration: BoxDecoration(
                border: Border.all(
                  color: ColorConstant.ffee,
                  width: 1.px,
                ),
                borderRadius: BorderRadius.circular(30.w),
              ),
              child: Text(
                copyText,
                style: copyStyle ?? TextStyleConstant().normal_3_22,
              ),
            ),
          ),
          behavior: HitTestBehavior.translucent,
          onTap: () async {
            await Utils.copyText2ClipBoard(clipboardText);
            toast('复制成功');
          },
        ),
      ],
    );
  }
}
